<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/static/common/default.jsp"%>
<html>
	<head>
	    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<style type="text/css">
			.select_option{
				width: 180px;
				z-index: 1;
				position: absolute;
			}
			.select_showbox{
				width: 175px;
			}
		</style>
		<link type="text/css" rel="stylesheet" href="${ctx}/static/tools/jquery-validationEngine/validationEngine.jquery.css"></link>
	</head>
	<body>
		<script type="text/javascript" src="${ctx}/static/tools/jquery-validationEngine/jquery.validationEngine.js"></script>
		<script type="text/javascript" src="${ctx}/static/tools/jquery-validationEngine/jquery.validationEngine-cn.js"></script>
		<div class="cinema_tip">
		    <div class="cinema_subject clearfix">
		        <div class="cinema_title">
		            <a href="javascript:void(0);">审批管理</a> >
		            <a id="userinfo_list_href" href="${ctx}/sys/mechanicalApply/list">机械审批</a> >
		            <a href="javascript:void(0);" class="cinema_option">审批</a>
		        </div>
		        <!-- <a onclick="javascript:history.back(-1);" class="movie_return">返回列表</a> -->
		        <a href="${ctx}/sys/mechanicalApply/list" class="movie_return">返回列表</a>
		    </div>
		</div>
		<div class="cinema_list">
			<form class="form-horizontal" onsubmit="return sysConsInfoModify();" id="sysConsInfoModifyForm"  name="sysConsInfoModifyForm" >
				<input type="hidden" id="teamId" name="teamId" value="${sysConsInfo.teamId}">
				<div class="movie_list">
					<dl class="movie_fill">
						<dt class="movie_word clearfix">
							<p>里程桩号：</p>
						</dt>
						<dd class="mleft_99">
							<div class="movie_type cinema_feed">
								<input id="mileageCode" type="text" name="mileageCode" value="${res.mileageCode}" class="validate[required,maxSize[100]]" maxlength="100" />
							</div>
						</dd>
					</dl>
					<div class="clearfix"></div>
					<dl class="movie_fill">
						<dl class="movie_fill">
						<dt class="movie_word clearfix">
							<p style="background-image: none;">机械申请内容: </p>
						</dt>
						<dd class="mleft_99">
							<div class="movie_type cinema_feed">
								<input id="applyContent" type="text" name="applyContent" value="${res.applyContent}" class="validate[required,maxSize[100]]" maxlength="100"/>
							</div>
						</dd>
					</dl>
					
					<div class="clearfix"></div>
					<dl class="movie_fill">
						<dl class="movie_fill">
						<dt class="movie_word clearfix">
							<p style="background-image: none;">项目名称: </p>
						</dt>
						<dd class="mleft_99">
							<div class="movie_type cinema_feed">
								<input id="projectName" type="text" name="projectName" value="${res.project.name}" class="validate[required,maxSize[100]]" maxlength="100"/>
							</div>
						</dd>
					</dl>
					<div class="clearfix"></div>
					<dl class="movie_fill">
						<dt class="movie_word clearfix">
							<p style="background-image: none;">工程类别：</p>
						</dt>
						<dd class="mleft_99">
							<div class="movie_type cinema_feed">
								 <c:choose>
                	                <c:when test="${res.projectId==1}">路基</c:when>
                	                <c:when test="${res.projectId==2}">路面</c:when>
                	                <c:when test="${res.projectId==3}">桥涵</c:when>
                	                <c:when test="${res.projectId==4}">隧道</c:when>
                	                <c:when test="${res.projectId==5}">其他</c:when>
                                 </c:choose>
							</div>
						</dd>
					</dl>
					<div class="clearfix"></div>
					<dl class="movie_fill">
						<dt class="movie_word clearfix">
							<p style="background-image: none;">机械类型 ：</p>
						</dt>
						<dd class="mleft_99">
							<div class="movie_type cinema_feed">
								<input id="mechanicalName" type="text" name="mechanicalName" value="${res.mechanical.mechanicalName}" class="width_320" maxlength="100" />
							</div>
						</dd>
					
					</dl>
					<div class="clearfix"></div>
					<dl class="movie_fill">
						<dt class="movie_word clearfix">
							<p style="background-image: none;">机械型号 ：</p>
						</dt>
						<dd class="mleft_99">
							<div class="movie_type cinema_feed">
								<input id="mechanicalModel" type="text" name="mechanicalModel" value="${res.mechanical.mechanicalModel}" class="width_320" maxlength="100" />
							</div>
						</dd>
					
					</dl>
					<div class="clearfix"></div>
					<dl class="movie_fill">
						<dt class="movie_word clearfix">
							<p style="background-image: none;">使用开始时间：</p>
						</dt>
						<dd class="mleft_99">
							<div class="movie_type cinema_feed">
								<input id="startTime" type="text" name="startTime" value="<fmt:formatDate value="${res.startTime}" type="both" pattern="yyyy-MM-dd HH"/>" class="width_320" maxlength="100" />
							</div>
						</dd>
					
					</dl>
					<div class="clearfix"></div>
					<dl class="movie_fill">
						<dt class="movie_word clearfix">
							<p style="background-image: none;">使用结束时间 ：</p>
						</dt>
						<dd class="mleft_99">
							<div class="movie_type cinema_feed">
								<input id="endTime" type="text" name="endTime" value="<fmt:formatDate value="${res.endTime}" type="both" pattern="yyyy-MM-dd HH"/>" class="width_320" maxlength="100" />
							</div>
						</dd>
					
					</dl>
					<div class="clearfix"></div>
					<dl class="movie_fill">
						<dt class="movie_word clearfix">
							<p style="background-image: none;">机械单价 ：</p>
						</dt>
						<dd class="mleft_99">
							<div class="movie_type cinema_feed">
								<input id="price" type="text" name="price" value="${res.price}" class="width_320" maxlength="100" />
							</div>
						</dd>
					
					</dl>
					<div class="clearfix"></div>
					<dl class="movie_fill">
						<dt class="movie_word clearfix">
							<p style="background-image: none;">台数 ：</p>
						</dt>
						<dd class="mleft_99">
							<div class="movie_type cinema_feed">
								<input id="quantity" type="text" name="quantity" value="${res.quantity}" class="width_320" maxlength="100" />
							</div>
						</dd>
					
					</dl>
					<div class="clearfix"></div>
					<dl class="movie_fill">
						<dt class="movie_word clearfix">
							<p style="background-image: none;">施工队 ：</p>
						</dt>
						<dd class="mleft_99">
							<div class="movie_type cinema_feed">
								<input id="teamname" type="text" name="teamname" value="${res.team.name}" class="width_320" maxlength="100" />
							</div>
						</dd>
					
					</dl>
					<div class="clearfix"></div>
					<dl class="movie_fill">
						<dt class="movie_word clearfix">
							<p style="background-image: none;">申请时间 ：</p>
						</dt>
						<dd class="mleft_99">
							<div class="movie_type cinema_feed">
								<input id="applyTime" type="text" name="applyTime" value="<fmt:formatDate value="${res.applyTime}" type="both" pattern="yyyy-MM-dd HH"/>" class="width_320" maxlength="100" />
							</div>
						</dd>
					
					</dl>
					<div class="clearfix"></div>
					<dl class="movie_fill">
						<dt class="movie_word clearfix">
							<p style="background-image: none;">附加照片 ：</p>
						</dt>
						<dd class="mleft_99">
							<div class="movie_type cinema_feed">
							<table><tr>
								<td><img hight="480px" width="240px"  style="padding:10px" src="${ctx}${res.frontImage}"></td>
								<td><img hight="480px" width="240px"  style="padding:10px" src="${ctx}${res.middleImage}"></td>
								<td><img hight="480px" width="240px"  style="padding:10px" src="${ctx}${res.behindImage}"></td>
							</tr></table>	
							</div>
						</dd>
					
					</dl>
					<div class="clearfix"></div>
					
					<c:choose>
            		<c:when test="${currentUser.roleId eq 3 && res.state==0}">
            		<div class="btn_box">
            			<table>
						<tr>
							<td><input type="button" id="approve" data-type="1" data-status="3" value="同意" class="cinema_inquiry"/></td>
							<td><input type="button" id="approve" data-type="2" data-status="-3" value="不同意" class="cinema_inquiry"/></td>
						</tr>
						</table>
            			
            		</div> 
            		</c:when>
	            	<c:when test="${currentUser.roleId eq 4 && res.state==3}">
	            		<table>
						<tr>
							<td><input type="button" id="approve" data-type="1" data-status="4" value="同意" class="cinema_inquiry"/></td>
							<td><input type="button" id="approve" data-type="2" data-status="-4" value="不同意" class="cinema_inquiry"/></td>
						</tr>
						</table>
	            	</c:when>	
	            	<c:when test="${currentUser.roleId eq 5 && res.state==4}">
	            		<table>
						<tr>
							<td><input type="button" id="approve" data-type="1" data-status="5" value="同意" class="cinema_inquiry"/></td>
							<td><input type="button" id="approve" data-type="2" data-status="-5" value="不同意" class="cinema_inquiry"/></td>
						</tr>
						</table>
	            	</c:when>
	            	<c:when test="${currentUser.roleId eq 6 && res.state==5}">
	            		<table>
						<tr>
							<td><input type="button" id="approve" data-type="1" data-status="6" value="同意" class="cinema_inquiry"/></td>
							<td><input type="button" id="approve" data-type="2" data-status="-6" value="不同意" class="cinema_inquiry"/></td>
						</tr>
						</table>
	            	</c:when>
         			</c:choose>
				</div>
			</form>
		</div>
		<script type="text/javascript">
		//项目基本信息修改
		$('#approve').click(function() {    	 
	    	 var status = jQuery("#approve").data('status');
	    	 var type = jQuery("#approve").data('type');
	    	 var approve_data = {
	    		'applyType': type,
	    		'status':status,
	    		'applyId':"${res.applyId}",
	    		'approveUserId':"${currentUser.user_id}",
	    		'approveLoginName':"${currentUser.loginName}",
	    		'approveUserName':"${currentUser.userName}"
	         }
    	 
	    	 $.ajax({
	  	        async: true,
	  	        type:"POST",
	  	        data:JSON.stringify(approve_data),
	  	        url: "${ctx}/sys/approve/todo?mid="+Math.random(),
	  	        dataType: "json",
	  	        headers : {  
	            	'Content-Type' : 'application/json;charset=utf-8'  
	            },
	              
	            success : function(data) {
	          		if (data != undefined && data.status != undefined
	          				&& data.status.trim() == '0') {
	          			window.location.href = "${ctx}/sys/mechanicalApply/list";
	          			/* window.opener = null; 
	          			window.open('', '_self'); 
	          			window.close()  */
	          			alert(data.error);
	          			result = true;
	          		} else {
	          			result = false;
	          			alert(data.error);
	          		}
	          	},
	  		},"json") 
     	});
	</script>
	</body>
</html>